package at.ac.tuwien.mg.wh.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;


@Entity
public class User implements Serializable {

	@Id
	private Long userId;
	@OneToMany(mappedBy="user", orphanRemoval=true)
	private List<ItemUser> itemUsers;
	
	private static final long serialVersionUID = 1L;

	
	
	public User(Long userId) {
		super();
		this.userId = userId;
	}
	public User() {
		super();
	}
	public Long getUserId() {
		return userId;
	}
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public List<ItemUser> getItemUsers() {
		
		if (itemUsers == null) {
			itemUsers = new ArrayList<ItemUser>();
        }
		return itemUsers;
	}
	public void setItemUsers(List<ItemUser> itemUsers) {
		this.itemUsers = itemUsers;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "User [userId=" + userId + ", itemUsers=" + itemUsers + "]";
	}

	

	
   
}
